# -*- coding: utf-8 -*-
# @Time : 2018/12/25 18:54
# @Author : Administrator
# @File : guestTest.py
# @Project : 4.Python
# @title : 参照接口文档进行guest接口测试
import requests,random
class test_guest():
    def data(self):
        index = random.randint(12, 500)
        index = str(index)
        name = '华为手机发布会' + index
        return index,name
    def test001(self):
        pass

    def test005(self):#发布会所有参数输入合法
        (index,name)=self.data()
        r=requests.post(url='http://127.0.0.1:8000/api/add_event/',
                        data={'eid':'%s'%index,'name':'%s'%name,'limit':'57','address':'成都','start_time':'2018-09-11 9:00:00'})

        print(r.text)
        print(r.json())
        actural = r.json()
        assert actural['status']==200
        assert actural['message']=='add event success'

if __name__ == '__main__':
    t=test_guest()
    t.test005()